Spawning habitat will be summarized for July, August, and September, whereas rearing habitat is summarized for June, July, and August.
##Interannual Variability of all Chinook habitat To summarize interannual variability of Chinook habitat we averaged temperatures from June 1 - September 30 for each year and plotted the results. Stanadard deviation of yearly averages represent the spatial variability of RCAs.| year | mean | std |
|---|---|---|
| 1980 | 8.17 | 2.21 |
| 1981 | 8.52 | 2.54 |
| 1982 | 8.17 | 2.20 |
| 1983 | 8.59 | 2.54 |
| 1984 | 8.99 | 2.36 |
| 1985 | 7.94 | 2.49 |
| 1986 | 8.18 | 2.25 |
| 1987 | 8.40 | 2.58 |
| 1988 | 8.55 | 2.40 |
| 1989 | 9.10 | 2.47 |
| 1990 | 8.64 | 2.30 |
| 1991 | 8.33 | 2.30 |
| 1992 | 7.78 | 3.13 |
| 1993 | 9.44 | 2.60 |
| 1994 | 8.63 | 2.56 |
| 1995 | 8.94 | 2.14 |
| 1996 | 8.17 | 2.62 |
| 1997 | 9.23 | 2.49 |
| 1998 | 8.30 | 2.31 |
| 1999 | 8.16 | 2.32 |
| 2000 | 8.07 | 2.49 |
| 2001 | 9.15 | 2.35 |
| 2002 | 8.76 | 2.40 |
| 2003 | 9.08 | 2.85 |
| 2004 | 9.36 | 3.20 |
| 2005 | 9.66 | 2.44 |
| 2006 | 7.97 | 2.08 |
| 2007 | 8.60 | 2.22 |
| 2008 | 7.65 | 2.23 |
| 2009 | 8.40 | 2.66 |
| 2010 | 8.25 | 2.22 |
| 2011 | 7.78 | 2.27 |
| 2012 | 7.31 | 2.18 |
| 2013 | 8.96 | 2.86 |
| 2014 | 8.52 | 2.50 |
| 2015 | 8.92 | 2.98 |
| 2016 | 9.73 | 2.59 |
| 2017 | 8.75 | 2.47 |
| 2018 | 8.90 | 2.32 |
| year | month | mean | std |
|---|---|---|---|
| 1980 | 6 | 7.69 | 2.04 |
| 1981 | 6 | 7.94 | 2.14 |
| 1982 | 6 | 7.09 | 2.01 |
| 1983 | 6 | 8.26 | 2.00 |
| 1984 | 6 | 8.57 | 2.03 |
| 1985 | 6 | 6.47 | 2.45 |
| 1986 | 6 | 7.48 | 2.33 |
| 1987 | 6 | 7.44 | 1.89 |
| 1988 | 6 | 8.16 | 1.95 |
| 1989 | 6 | 7.89 | 2.50 |
| 1990 | 6 | 8.59 | 2.17 |
| 1991 | 6 | 7.88 | 2.48 |
| 1992 | 6 | 7.98 | 2.25 |
| 1993 | 6 | 8.39 | 2.07 |
| 1994 | 6 | 8.23 | 2.28 |
| 1995 | 6 | 8.08 | 2.36 |
| 1996 | 6 | 7.81 | 2.29 |
| 1997 | 6 | 8.75 | 2.72 |
| 1998 | 6 | 7.90 | 2.15 |
| 1999 | 6 | 7.43 | 2.13 |
| 2000 | 6 | 7.51 | 2.31 |
| 2001 | 6 | 9.17 | 2.32 |
| 2002 | 6 | 7.96 | 2.30 |
| 2003 | 6 | 8.11 | 2.20 |
| 2004 | 6 | 9.38 | 2.45 |
| 2005 | 6 | 9.37 | 2.24 |
| 2006 | 6 | 7.36 | 1.89 |
| 2007 | 6 | 7.99 | 2.29 |
| 2008 | 6 | 6.75 | 2.11 |
| 2009 | 6 | 7.51 | 2.02 |
| 2010 | 6 | 7.43 | 2.01 |
| 2011 | 6 | 7.14 | 2.14 |
| 2012 | 6 | 7.23 | 2.46 |
| 2013 | 6 | 9.51 | 2.70 |
| 2014 | 6 | 7.48 | 2.21 |
| 2015 | 6 | 9.51 | 3.05 |
| 2016 | 6 | 9.37 | 2.18 |
| 2017 | 6 | 8.22 | 2.01 |
| 2018 | 6 | 7.90 | 2.03 |
| year | month | mean | std |
|---|---|---|---|
| 1980 | 7 | 9.82 | 2.02 |
| 1981 | 7 | 10.26 | 1.92 |
| 1982 | 7 | 9.57 | 2.11 |
| 1983 | 7 | 10.31 | 1.82 |
| 1984 | 7 | 10.23 | 1.93 |
| 1985 | 7 | 9.96 | 1.97 |
| 1986 | 7 | 9.82 | 2.02 |
| 1987 | 7 | 10.10 | 2.44 |
| 1988 | 7 | 10.28 | 2.02 |
| 1989 | 7 | 10.64 | 2.07 |
| 1990 | 7 | 9.85 | 2.02 |
| 1991 | 7 | 9.70 | 2.14 |
| 1992 | 7 | 10.01 | 2.24 |
| 1993 | 7 | 11.49 | 2.27 |
| 1994 | 7 | 9.95 | 2.11 |
| 1995 | 7 | 10.31 | 1.97 |
| 1996 | 7 | 9.99 | 2.03 |
| 1997 | 7 | 10.94 | 2.00 |
| 1998 | 7 | 10.08 | 1.89 |
| 1999 | 7 | 9.71 | 2.09 |
| 2000 | 7 | 9.64 | 2.23 |
| 2001 | 7 | 10.34 | 2.08 |
| 2002 | 7 | 10.46 | 2.02 |
| 2003 | 7 | 11.61 | 2.15 |
| 2004 | 7 | 11.58 | 2.45 |
| 2005 | 7 | 11.62 | 1.96 |
| 2006 | 7 | 9.48 | 2.01 |
| 2007 | 7 | 9.95 | 1.90 |
| 2008 | 7 | 8.89 | 2.08 |
| 2009 | 7 | 10.76 | 2.28 |
| 2010 | 7 | 9.36 | 1.99 |
| 2011 | 7 | 9.31 | 2.01 |
| 2012 | 7 | 8.11 | 2.07 |
| 2013 | 7 | 10.84 | 2.44 |
| 2014 | 7 | 10.36 | 2.02 |
| 2015 | 7 | 10.73 | 2.01 |
| 2016 | 7 | 11.75 | 2.09 |
| 2017 | 7 | 10.95 | 2.05 |
| 2018 | 7 | 10.52 | 2.32 |
| year | month | mean | std |
|---|---|---|---|
| 1980 | 8 | 8.64 | 1.75 |
| 1981 | 8 | 9.54 | 1.73 |
| 1982 | 8 | 9.20 | 1.55 |
| 1983 | 8 | 9.72 | 1.87 |
| 1984 | 8 | 10.20 | 2.26 |
| 1985 | 8 | 8.81 | 1.74 |
| 1986 | 8 | 8.69 | 1.68 |
| 1987 | 8 | 9.86 | 1.68 |
| 1988 | 8 | 9.52 | 1.71 |
| 1989 | 8 | 10.16 | 1.90 |
| 1990 | 8 | 9.45 | 1.90 |
| 1991 | 8 | 8.66 | 1.97 |
| 1992 | 8 | 8.75 | 2.30 |
| 1993 | 8 | 10.48 | 1.75 |
| 1994 | 8 | 9.87 | 2.21 |
| 1995 | 8 | 9.43 | 1.69 |
| 1996 | 8 | 9.11 | 1.77 |
| 1997 | 8 | 9.81 | 1.88 |
| 1998 | 8 | 8.64 | 2.06 |
| 1999 | 8 | 8.96 | 1.96 |
| 2000 | 8 | 9.03 | 2.02 |
| 2001 | 8 | 10.09 | 1.80 |
| 2002 | 8 | 9.55 | 1.95 |
| 2003 | 8 | 10.03 | 2.16 |
| 2004 | 8 | 10.74 | 2.03 |
| 2005 | 8 | 10.22 | 1.80 |
| 2006 | 8 | 8.33 | 1.77 |
| 2007 | 8 | 9.46 | 1.73 |
| 2008 | 8 | 8.56 | 1.78 |
| 2009 | 8 | 8.91 | 1.78 |
| 2010 | 8 | 9.18 | 1.83 |
| 2011 | 8 | 8.45 | 1.79 |
| 2012 | 8 | 7.89 | 1.78 |
| 2013 | 8 | 9.29 | 1.78 |
| 2014 | 8 | 9.44 | 1.96 |
| 2015 | 8 | 9.54 | 2.13 |
| 2016 | 8 | 10.49 | 1.67 |
| 2017 | 8 | 9.11 | 2.10 |
| 2018 | 8 | 9.55 | 2.11 |
| year | month | mean | std |
|---|---|---|---|
| 1980 | 9 | 6.45 | 1.45 |
| 1981 | 9 | 6.25 | 2.24 |
| 1982 | 9 | 6.73 | 1.48 |
| 1983 | 9 | 5.96 | 1.94 |
| 1984 | 9 | 6.88 | 1.28 |
| 1985 | 9 | 6.43 | 1.60 |
| 1986 | 9 | 6.66 | 1.52 |
| 1987 | 9 | 6.10 | 1.76 |
| 1988 | 9 | 6.15 | 1.58 |
| 1989 | 9 | 7.61 | 1.77 |
| 1990 | 9 | 6.63 | 1.64 |
| 1991 | 9 | 7.03 | 1.60 |
| 1992 | 9 | 4.27 | 2.38 |
| 1993 | 9 | 7.28 | 1.89 |
| 1994 | 9 | 6.38 | 1.81 |
| 1995 | 9 | 7.89 | 1.43 |
| 1996 | 9 | 5.67 | 2.13 |
| 1997 | 9 | 7.35 | 1.71 |
| 1998 | 9 | 6.48 | 1.44 |
| 1999 | 9 | 6.47 | 1.54 |
| 2000 | 9 | 6.00 | 1.55 |
| 2001 | 9 | 6.92 | 1.40 |
| 2002 | 9 | 6.98 | 1.59 |
| 2003 | 9 | 6.46 | 1.83 |
| 2004 | 9 | 5.64 | 2.06 |
| 2005 | 9 | 7.35 | 1.49 |
| 2006 | 9 | 6.64 | 1.42 |
| 2007 | 9 | 6.95 | 1.51 |
| 2008 | 9 | 6.31 | 1.72 |
| 2009 | 9 | 6.34 | 2.25 |
| 2010 | 9 | 6.95 | 1.99 |
| 2011 | 9 | 6.13 | 1.68 |
| 2012 | 9 | 5.97 | 1.68 |
| 2013 | 9 | 6.11 | 2.06 |
| 2014 | 9 | 6.70 | 1.87 |
| 2015 | 9 | 5.81 | 2.06 |
| 2016 | 9 | 7.20 | 1.95 |
| 2017 | 9 | 6.63 | 1.37 |
| 2018 | 9 | 7.55 | 1.32 |
#Mean daily temperatures across 38 year period
#histograms of percent habitat for each degree celcius - Chinook Presence habitat
#histograms of percent habitat for each degree celcius - Chinook Spawning habitat
#histograms of percent habitat for each degree celcius - Chinook Rearing habitat
##Daily mean tempertures for each year (1980-2018)
#Animate by Year using gganimate
#https://www.datanovia.com/en/blog/gganimate-how-to-create-plots-with-beautiful-animation-in-r/
#shadow fade with old years in background
theme_set(theme_bw())
ani <- ggplot(all_years, aes(x = day, y = mean_yr, color = as.factor(year))) +
geom_smooth(se=FALSE, show.legend = FALSE) +
scale_size(range = c(2, 12)) +
transition_states(year, transition_length = 1, state_length = 1) + shadow_mark(alpha=0.3, size=0.7) +
transition_time (year) +
labs(x = "Day of Year", y = "Daily mean Stream Temperature", title = "Year: {as.integer(frame_time)}")
animate(ani, duration=50, fps=1)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
#try the "Let data gradually appear" with month time series
K_p2 <- preds %>% mutate(month=month(date), day2=(day(date))) %>% mutate(decade=case_when(year< 1990 ~ 1980, year >= 1990 & year < 2000 ~ 1990, year >=2000 & year < 2010 ~ 2000, year>2009 ~ 2010)) %>% filter(K_p == 1)
all_years2 <- K_p2 %>% group_by(month, day2) %>%
summarize(mean_mth = mean(preds))
ani2 <- ggplot(all_years2, aes(x = day2, y = mean_mth, color=factor(month))) +
geom_line() +
labs(x = "Day of Month", y = "Stream Temperature", title = "Average Daily Temperatures 1980-2018")
ani2 + transition_reveal(day2)
##Animate months by decade
all_years22 <- K_p2 %>% group_by(month, day2, decade) %>%
summarize(mean_mth_dec = mean(preds))
ggplot(all_years22, aes(x = day2, y = mean_mth_dec, color=factor(month))) +
geom_line() + facet_wrap(~decade) +
labs(x = "Day of Month", y = "Stream Temperature", title = "Average Daily Temperatures by decade")
ggsave("Anchor_chinook_plots/Average Daily Temps Animated.jpeg", plot=last_plot())
## Saving 4 x 4 in image
ani3 <- ggplot(all_years22, aes(x = day2, y = mean_mth_dec, color=factor(month))) +
geom_line() +
labs(x = "Day of Month", y = "Stream Temperature", title = "Average Daily Temperatures by decade")
ani3 + transition_reveal(day2) + facet_wrap(~decade)
##Summarize predictions by decades and plot
##Calculate and plot Temperature Anomolies!
#Filter for spawning time period - Chinook reach their spawning areas between July and September - DESCENDING LIMB!!!!
#Filter for core rearing - June-August